function loadImg(src) {
    return new Promise((resolve,reject) =>{
        let img = document.createElement('img')
        // let img = new Image()
        img.onload = (() =>resolve(img))
        img.onerror = (() => reject('图片加载失败'))
        img.src = src
        var picdiv = document.getElementById('mypic')
        console.log("picdiv"+picdiv)  //[object HTMLDivElement]
        picdiv.appendChild(img)
        //通过类选择器无法添加该元素
        // var picdiv1 = document.getElementsByClassName('mypic1')
        // console.log("picdiv1"+picdiv1)  //[[object HTMLCollection]]

    })
}

let src = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1566754227818&di=2900b543e425b4a8986fe522785c0396&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn16%2F298%2Fw640h458%2F20180625%2Fd1e1-hencxtt8482959.jpg"
let result = loadImg(src)
result.then((img) =>{
    console.log(`width: ${ img.width}`)
    return img
}).then((img) =>{
    console.log(`height:${img.height}`)
}).catch((ex) =>{
    alert(ex)
})